wayland: Make window opacity work
authorMatthias Clasen <mclasen@redhat.com>
Tue, 28 Oct 2014 14:28:23 +0000 (10:28 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 28 Oct 2014 14:28:23 +0000 (10:28 -0400)
Under wayland, the compositor doesn't have a 'overall window alpha'
knob, we just need to add the alpha to the buffers we send.
Client-side alpha, if you want to call it that.

Implement this by reusing the existing alpha support for non-toplevel
widgets. As a side-effect of the implementation, windows with RGBA
visual under X will now also use per-pixel alpha, instead of
overall alpha.

gtk/gtkwidget.c
gtk/gtkwindow.c

index 956543910c4fe6fe694b5ca02ec89f56918b0e17..f3e4958ae98b80a80f013385bc31376264a396ca 100644 (file)
@@ -7122,8 +7122,9 @@ _gtk_widget_draw (GtkWidget *widget,
   cairo_save (cr);
 
   push_group =
-    (widget->priv->alpha != 255 &&
-     !gtk_widget_is_toplevel (widget));
+    widget->priv->alpha != 255 &&
+    (!gtk_widget_is_toplevel (widget) ||
+     gtk_widget_get_visual (widget) == gdk_screen_get_rgba_visual (gtk_widget_get_screen (widget)));
 
   if (push_group)
     cairo_push_group (cr);
@@ -15958,7 +15959,8 @@ gtk_widget_update_alpha (GtkWidget *widget)
 
   if (gtk_widget_get_realized (widget))
     {
-      if (gtk_widget_is_toplevel (widget))
+      if (gtk_widget_is_toplevel (widget) &&
+          gtk_widget_get_visual (widget) != gdk_screen_get_rgba_visual (gtk_widget_get_screen (widget)))
        gdk_window_set_opacity (priv->window, priv->alpha / 255.0);
 
       gtk_widget_queue_draw (widget);
index 0b0365fa533ee2876663ad947148e2454689ed9b..6bfe8364236a0f26c080a58acbf10d99d04e3a19 100644 (file)
@@ -6761,6 +6761,9 @@ update_opaque_region (GtkWindow           *window,
       is_opaque = (color->alpha >= 1.0);
     }
 
+  if (gtk_widget_get_opacity (widget) < 1.0)
+    is_opaque = FALSE;
+
   if (is_opaque)
     {
       cairo_rectangle_int_t rect;